<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>日志管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
	<div class="demoTable" style="padding:10px 0 0 15px">
    	<div class="layui-inline">
        	<input class="layui-input" name="keyWord" id="keyWord" placeholder="请输入异常信息" autocomplete="off">
    	</div> &nbsp; &nbsp; &nbsp; &nbsp;
    	<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
	</div>
	
	<table class="layui-hide" id="test" lay-filter="test"></table>
	
	<!-- <div id="formDiv" hidden>
		<form class="layui-form" id="addform">
			<input type="hidden" id="id" name="id">
			<label class="layui-form-label">IP地址</label><input lay-verify="ip" class="layui-input" type="text" id="ip" name="ip" style="width:300px"><br>
			<label class="layui-form-label">类名</label><input lay-verify="className" class="layui-input" type="text" id="className" name="className" style="width:300px"><br>
			<label class="layui-form-label">方法名</label><input lay-verify="methodName" class="layui-input" type="text" id="methodName" name="methodName" style="width:300px"><br>
			<label class="layui-form-label">异常类型</label><input lay-verify="exceptionType" class="layui-input" type="text" id="exceptionType" name="exceptionType" style="width:300px"><br>
			<label class="layui-form-label">发生时间</label><input lay-verify="addtime" class="layui-input" type="text" id="addtime" name="addtime" style="width:300px"><br>
			<label class="layui-form-label">异常信息</label><input lay-verify="exceptionMsg" class="layui-input" type="text" id="exceptionMsg" name="exceptionMsg" style="width:300px"><br>
			<button class="layui-btn layui-btn-blue" lay-submit lay-filter="addform" style="margin-left:140px">立即提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</form>
	</div> -->

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="delete"><i class="layui-icon layui-icon-delete">批量删除</i></button>
	</div>
</script>
 
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>

<script>
layui.use(['table','layer','upload','form'], function(){
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	
	var $ = layui.jquery, active = {
			reload:function () {
				var exceptionMsg = $("#keyWord").val();
				table.reload('contenttable',{
					method:'get',
					where:{exceptionMsg: exceptionMsg},
					page:{
						curr:1  //重新从第一页开始
					}
				}); 
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/exceptionLogMana/listPageExceptionLog.do'
	    ,toolbar: '#toolbarDemo'
	    ,title: '异常日志'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,cols: [[
	    	{type: 'checkbox', fixed: 'left'}
	    	,{field:'', title:'序号', sort: true, type:'numbers'}
	      	,{field:'ip', title:'ip地址'}
	      	,{field:'className', title:'类名'}
	      	,{field:'methodName', title:'方法名'}
	      	,{field:'exceptionType', title:'异常类型'}
	      	,{field:'addtime', title:'发生时间'}
	      	,{field:'exceptionMsg', title:'异常信息'}
	    ]]
	    ,page: true
	});
  
	//头工具栏事件
	table.on('toolbar(test)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'delete':
	        	var data = checkStatus.data;
	        	var str = "";
	        	if(data.length==0){
	        		toastr.warning("请至少选择一条记录！");
	        	}else{
	        		for(var i=0;i<data.length;i++){
		        		str += data[i].id;
		        		if(i != data.length-1){
		        			str += ",";
		        		}
		        	}
		        	layer.confirm('确定删除吗？', function(index){
		        		$.ajax({
					    	type:'post',
					    	url:'${pageContext.request.contextPath }/exceptionLogMana/deleteExceptionLog.do',
					    	data:{"str" : str},
					    	success:function(data){
					    		if(data>0){
					    			toastr.success("删除成功！");
					    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
										//关闭模态框
										// 父页面刷新
										window.location.reload();  
									},2000); 
					    		}else{
					    			toastr.error("删除失败！");
					    		}
					    	}
					    }); 
		        	});
	        	}
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
});  

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>
</body>
</html>